package com.j2eefast.flowable.bpm.service;


import cn.hutool.core.util.IdUtil;
import com.j2eefast.flowable.bpm.entity.bpmCrmRemittanceEntity;
import com.j2eefast.flowable.bpm.mapper.bpmCrmRemittanceMapper;
import com.j2eefast.common.core.mutidatasource.annotaion.DataSource;
import com.j2eefast.common.core.page.Query;
import com.j2eefast.common.core.utils.PageUtil;
import com.j2eefast.common.core.utils.ToolUtil;
import com.j2eefast.framework.utils.Constant;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import javax.annotation.Resource;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.Arrays;
/**
 *
 * 汇款信息Service接口
 * @author: yhli
 * @date 2020-06-28 14:12
 */
@Service
public class bpmCrmRemittanceService extends ServiceImpl<bpmCrmRemittanceMapper,bpmCrmRemittanceEntity> {

	@Resource
	private bpmCrmRemittanceMapper bpmCrmRemittanceMapper;

	/**
	 * mybaitis-plus 页面分页查询
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params) {
        QueryWrapper<bpmCrmRemittanceEntity> queryWrapper = new QueryWrapper<bpmCrmRemittanceEntity>();
              String saleCode = (String) params.get("saleCode");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleCode), "sale_code", saleCode);
                               String saleUserid = (String) params.get("saleUserid");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleUserid), "sale_userid", saleUserid);
          String saleOrderNumber = (String) params.get("saleOrderNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(saleOrderNumber), "sale_order_number", saleOrderNumber);
          String outCarVin = (String) params.get("outCarVin");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVin), "out_car_vin", outCarVin);
          String outCarVehicle = (String) params.get("outCarVehicle");
         queryWrapper.eq(ToolUtil.isNotEmpty(outCarVehicle), "out_car_vehicle", outCarVehicle);
          String remittanceCostTime = (String) params.get("remittanceCostTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceCostTime), "remittance_cost_time", remittanceCostTime);
          String remittancereimburseAmount = (String) params.get("remittancereimburseAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittancereimburseAmount), "remittance_reimburse_amount", remittancereimburseAmount);
          String remittanceVoucherFilepath = (String) params.get("remittanceVoucherFilepath");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceVoucherFilepath), "remittance_voucher_filepath", remittanceVoucherFilepath);
          String remittanceRemark = (String) params.get("remittanceRemark");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceRemark), "remittance_remark", remittanceRemark);
          String remittanceFirstPaymethod = (String) params.get("remittanceFirstPaymethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceFirstPaymethod), "remittance_first_paymethod", remittanceFirstPaymethod);
             String remittanceRecipientName = (String) params.get("remittanceRecipientName");
        queryWrapper.like(ToolUtil.isNotEmpty(remittanceRecipientName), "remittance_recipient_name", remittanceRecipientName);
          String remittanceRecipientAddress = (String) params.get("remittanceRecipientAddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceRecipientAddress), "remittance_recipient_address", remittanceRecipientAddress);
          String remittanceRecipientPhone = (String) params.get("remittanceRecipientPhone");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceRecipientPhone), "remittance_recipient_phone", remittanceRecipientPhone);
          String remittanceAccount = (String) params.get("remittanceAccount");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceAccount), "remittance_account", remittanceAccount);
          String remittanceRouting = (String) params.get("remittanceRouting");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceRouting), "remittance_routing", remittanceRouting);
          String remittanceBankaddress = (String) params.get("remittanceBankaddress");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceBankaddress), "remittance_bankaddress", remittanceBankaddress);
          String remittanceRmbPaymethod = (String) params.get("remittanceRmbPaymethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceRmbPaymethod), "remittance_rmb_paymethod", remittanceRmbPaymethod);
          String remittanceRmbBankname = (String) params.get("remittanceRmbBankname");
        queryWrapper.like(ToolUtil.isNotEmpty(remittanceRmbBankname), "remittance_rmb_bankname", remittanceRmbBankname);
          String remittanceRmbBankaccount = (String) params.get("remittanceRmbBankaccount");
         queryWrapper.eq(ToolUtil.isNotEmpty(remittanceRmbBankaccount), "remittance_rmb_bankaccount", remittanceRmbBankaccount);
             String approvalAmount = (String) params.get("approvalAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalAmount), "approval_amount", approvalAmount);
          String approvalCashier = (String) params.get("approvalCashier");
         queryWrapper.eq(ToolUtil.isNotEmpty(approvalCashier), "approval_cashier", approvalCashier);
             String reimburseProportion = (String) params.get("reimburseProportion");
         queryWrapper.eq(ToolUtil.isNotEmpty(reimburseProportion), "reimburse_proportion", reimburseProportion);
          String reimburseAmount = (String) params.get("reimburseAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(reimburseAmount), "reimburse_amount", reimburseAmount);
          String reimburseFinanceapproval = (String) params.get("reimburseFinanceapproval");
         queryWrapper.eq(ToolUtil.isNotEmpty(reimburseFinanceapproval), "reimburse_financeapproval", reimburseFinanceapproval);
             String payTime = (String) params.get("payTime");
         queryWrapper.eq(ToolUtil.isNotEmpty(payTime), "pay_time", payTime);
          String payMethod = (String) params.get("payMethod");
         queryWrapper.eq(ToolUtil.isNotEmpty(payMethod), "pay_method", payMethod);
          String payProofFilepath = (String) params.get("payProofFilepath");
         queryWrapper.eq(ToolUtil.isNotEmpty(payProofFilepath), "pay_proof_filepath", payProofFilepath);
          String payReceiptNumber = (String) params.get("payReceiptNumber");
         queryWrapper.eq(ToolUtil.isNotEmpty(payReceiptNumber), "pay_receipt_number", payReceiptNumber);
             String cashierResult = (String) params.get("cashierResult");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierResult), "cashier_result", cashierResult);
          String cashierAmount = (String) params.get("cashierAmount");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierAmount), "cashier_amount", cashierAmount);
          String cashierMemo = (String) params.get("cashierMemo");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierMemo), "cashier_memo", cashierMemo);
          String cashierPaysumamount = (String) params.get("cashierPaysumamount");
         queryWrapper.eq(ToolUtil.isNotEmpty(cashierPaysumamount), "cashier_paysumamount", cashierPaysumamount);
     		Page<bpmCrmRemittanceEntity> page = bpmCrmRemittanceMapper.selectPage(new Query<bpmCrmRemittanceEntity>(params).getPage(), queryWrapper);
		return new PageUtil(page);
    }

    /**
     * 自定义分页查询，含关联实体对像
     */
    @DataSource(name="FLOWABLE")
	public PageUtil findPage(Map<String, Object> params,bpmCrmRemittanceEntity bpmCrmRemittanceEntity) {
		Page<bpmCrmRemittanceEntity> page = bpmCrmRemittanceMapper.findPage(new Query<bpmCrmRemittanceEntity>(params).getPage(), bpmCrmRemittanceEntity,(String) params.get(Constant.SQL_FILTER))  ;
		return new PageUtil(page);
	}
	/**
     * 批量删除
     */
    @DataSource(name="FLOWABLE")
	@Transactional(rollbackFor = Exception.class)
	public boolean deletebpmCrmRemittanceByIds(String[] ids) {
		return removeByIds(Arrays.asList(ids));
	}

	/**
     * 单个删除
     */
    @DataSource(name="FLOWABLE")
	public boolean deletebpmCrmRemittanceById(String id) {
		return removeById(id);
	}

	/**
     * 保存
     */
    @DataSource(name="FLOWABLE")
	public boolean savebpmCrmRemittance(bpmCrmRemittanceEntity bpmCrmRemittance){
        bpmCrmRemittance.setId(IdUtil.fastSimpleUUID());
        return save(bpmCrmRemittance);
    }

	/**
     * 修改根居ID
     */
    @DataSource(name="FLOWABLE")
	public boolean updatebpmCrmRemittanceById(bpmCrmRemittanceEntity bpmCrmRemittance) {
		return updateById(bpmCrmRemittance);
	}

	/**
     * 根居ID获取对象
     */
    @DataSource(name="FLOWABLE")
	public bpmCrmRemittanceEntity getbpmCrmRemittanceById(String id){
		return getById(id);
	}
}
